package poker;
import javax.swing.*;
import java.awt.*;
import java.util.*;
import javax.swing.border.*;

public class MyTabbedPanel extends JPanel {
	
	MyTabButton activeTab;
	JPanel tabs = new JPanel();
	DefaultSettingsPanelGUI content;
	SettingsGUI sg;
	public MyTabbedPanel()
	{
		this.sg = sg;
		setLayout( new BoxLayout(this, BoxLayout.X_AXIS) );
		tabs.setLayout( new BoxLayout(tabs, BoxLayout.Y_AXIS) );
		tabs.setMaximumSize( new Dimension(100, 500) );
		tabs.setPreferredSize( new Dimension(100, 500) );
		tabs.setMinimumSize( new Dimension( 100, 500) );
		tabs.setBorder(new BevelBorder(BevelBorder.LOWERED) );
		tabs.setBackground(Color.WHITE);
		tabs.add( Box.createRigidArea( new Dimension(5, 5) ) );
		add(tabs);
	}
	
	public void addTab(String tabname, DefaultSettingsPanelGUI content)
	{
		MyTabButton mtb = new MyTabButton(tabname, content, this);
		tabs.add( mtb );
		if(activeTab == null)
		{
			this.content = content;
			activeTab = mtb;
			activeTab.setActive(true);
			this.add(this.content);
			validate();
		}
	}
	
	public void setContent(DefaultSettingsPanelGUI content, MyTabButton tab)
	{
		
		if(activeTab != null)
		{
			activeTab.setActive(false);
		}
		activeTab = tab;

		this.remove(this.content);
		this.validate();
		this.repaint();
		this.content.validate();
		super.validate();
		super.repaint();
		this.content = content;
		this.add(this.content);
		this.validate();
		this.repaint();
		super.validate();
		super.repaint();
		this.content.validate();
	}
}
